package com.swsc.xapp.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.swsc.xapp.baseContent.SplashActivity;

/**
 * @Author chencl
 * @Date 2022/7/18 14:36
 * @Version 1.0
 * @Description
 */
public class AutoStartBroadcastReceiver extends BroadcastReceiver {
    private static final String ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        //开机启动
        if (ACTION.equals(intent.getAction())) {
            //MainActivity.calss为你要打开的界面，如果没有界面就可以用service代替
            Intent mainIntent = new Intent(context, SplashActivity.class);
            // 在BroadcastReceiver中显示Activity，必须要设置FLAG_ACTIVITY_NEW_TASK标志
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);
        }
    }
}
